﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace FrontDisplay
{
    internal class ColorAnimationEx : ColorAnimation
    {
        public ColorAnimationEx() { }

        public ColorAnimationEx(Color color, Duration duration) : base(color, duration) { }

        public event EventHandler ColorChanged;

        protected override System.Windows.Media.Animation.Clock AllocateClock()
        {
            System.Windows.Media.Animation.Clock clock = base.AllocateClock();
            clock.CurrentTimeInvalidated += ClockCurrentTimeInvalidated;
            return clock;
        }

        private void ClockCurrentTimeInvalidated(object sender, EventArgs e)
        {
            EventHandler changed = ColorChanged;
            if (changed != null) changed(this, EventArgs.Empty);
        }
    }
}
